package org.zxw.controller.aiMotionAnalysisSystem;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.zxw.pojo.vo.Result;
import org.zxw.service.VideoAnalysisService;

@RestController
@RequestMapping("/api/v1/video/")
@Slf4j
public class VideoAnalysisController {

    private VideoAnalysisService videoAnalysisService;

    public VideoAnalysisController(VideoAnalysisService videoAnalysisService) {
        this.videoAnalysisService = videoAnalysisService;
    }

    /**
     * 视频动作解析
     * @param video
     * @return
     */
    @PostMapping("/analyze")
    public Result analyzeVideo(@RequestParam("video") MultipartFile video) {
        log.info("开始视频动作解析");
        try {
            String reasult = videoAnalysisService.analyzeVideo(video);
            return Result.success(reasult);
        } catch (Exception e) {
            log.info("视频解析失败：", e);
            return Result.error("视频解析失败");
        }
    }
}